import TurnTable from "../home/TurnTable";
import TurnTableSystem from "../system/TurnTableSystem";
import Util from "../../../StartAb/Util";
import { ITask } from "./ITask";

export class TaskSpin extends ITask {
    
    _levelCnt = 0;
    
    constructor(lvCnt: number, rewardCoin: number) {
        super();
        this._levelCnt = lvCnt;
        this._rewardCoin = rewardCoin
    }
    
    description() {
        return Util.getMulLangText("spintask")
    }

    isDone(): boolean {
        return TurnTableSystem.currentTurnedTimes >= this._levelCnt;
    }

    progressString(): string {
        return Math.min(this._levelCnt, TurnTableSystem.currentTurnedTimes) + "/" + this._levelCnt;
    }

    progressPercent(): number {
        return Math.min(TurnTableSystem.currentTurnedTimes / this._levelCnt, 1.0);
    }

    toComplete(): void {
        TurnTable.show()
        let node = cc.find("/Canvas/DailyTaskRoot")
        node && node.destroy()
    }
    
}